/**
 * 载入项目引导文件
 */
require('./bootstrap');

window.Vue = require('vue');

//标签输入，官方网址：http://www.vue-tags-input.com/#/
import InputTag from 'vue-input-tag';
//时间控件，官网：https://github.com/weifeiyue/vue-datepicker-local
import VueDatepickerLocal from 'vue-datepicker-local'

Vue.component('MaterialSelecter', require('../components/MaterialSelecter.vue'));
Vue.component('MaterialPreview', require('../components/MaterialPreview.vue'));
Vue.component('WebuploaderSingle', require('../components/WebuploaderSingle.vue'));

let box;

const app = new Vue({
    el: '#wrapper',
    data: {
        autuReplyData:page_params.data_autoreply,
    },
    watch:{
        autuReplyData:{
            handler:function(nowVal, oldVal){
                if (nowVal.msg_type == 'music'){//重新初始化上传控件
                    this.$nextTick(function() {
                        this.$refs.uploadThumbViewUrl.refresh();
                    });
                }
            },
            deep:true
        },
    },
    methods:{
        choiceMaterial:function(materialData){//选择素材回调
            this.autuReplyData.material = materialData;
        },
        showMaterialSelecter:function () {
            this.$refs.materialSelecterBox.showBox();
        },
        save:function(){
            let loadBox = layer.load(1, {
                shade: [0.3,'#fff'] //0.1透明度的白色背景
            });
            let url_save = this.autuReplyData.id ? page_params.url_edit : page_params.url_add;
            utils.ajaxPost(url_save, this.autuReplyData, (response, data) => {
                layer.close(loadBox);
                utils.showToastr(response.data, 'go');
            });
        },
    },
    components: {
        InputTag,VueDatepickerLocal
    },
});